const range = (size) =>
    Object.fromEntries(
        [...Array(size).keys()]
            .slice(1)
            .map((i) => [`${i}_${size}`,`${(i / size) * 100}%`])
    );
const generateSpacing = (num) => {
    return new Array(num + 1).fill(1).reduce(
        (cur,next,index) => ({...cur,[index]: `${index * 2}rpx`}),
        {}
    );
};

module.exports = {
    prefixer: false,
    separator: "_",
    compile: false,
    globalUtility: false,
    darkMode: "media",
    corePlugins: {
        preflight: false,
        divideColor: false,
        divideOpacity: false,
        divideStyle: false,
        divideWidth: false,
        space: false,
        placeholderColor: false,
        placeholderOpacity: false,
        transitionProperty: false,
        // 涉及到通配符（*），wx 小程序不支持
        ringWidth: false,
        ringColor: false,
        ringOpacity: false,
        ringOffsetWidth: false,
        ringOffsetColor: false,
        // web 浏览器相关功能，wx 小程序不支持
        appearance: false,
        cursor: false,
        outline: false,
        placeholderColor: false,
        pointerEvents: false,
        stroke: false,
        tableLayout: false,
        userSelect: false,
    },
    exclude: [/([0-9]{1,}[.][0-9]*)$/],
    theme: {
        spacing: {
            ...generateSpacing(201),
        },
        width: (theme) => ({
            auto: "auto",
            full: "100%",
            screen: "100vw",
            ...theme("spacing"),
        }),
        maxWidth: (theme) => ({
            ...theme("width"),
        }),
        minWidth: (theme) => ({
            ...theme("width"),
        }),
        height: (theme) => ({
            auto: "auto",
            full: "100%",
            screen: "100vh",
            ...theme("spacing"),
        }),
        minHeight: (theme) => ({
            ...theme("height"),
        }),
        maxHeight: (theme) => ({
            ...theme("height"),
        }),
        fontSize: (theme) => theme("spacing"),
        borderWidth: (theme) => theme("spacing"),
        lineHeight: (theme) => theme("spacing"),
        translate: (theme) => theme("spacing"),
        inset: (theme) => theme("spacing"),
        borderRadius: (theme) => theme("spacing"),
    },
};
